package com.example.mystoryapp2.ui.base

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.databinding.DataBindingUtil
import androidx.databinding.ViewDataBinding
import androidx.fragment.app.Fragment

/**
 * same like the base activity
 */
abstract class BaseFragment<T : ViewDataBinding> : Fragment() {
    open lateinit var mView: View
    open lateinit var mDataBinding: T
    override fun onCreateView(
        inflater: LayoutInflater,
        container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {

        mDataBinding = DataBindingUtil.inflate(
            inflater,
            getLayoutId(),
            container,
            false
        )
        mDataBinding.lifecycleOwner = this
        mView = mDataBinding.root
        onInitView(mView)
        return mView
    }

    open fun onInitView(view: View) {
        // nothing to do
    }

    abstract fun getLayoutId(): Int
}

